﻿using System.Runtime.Serialization;
using System.Security;

namespace System
{
    public class WeakReference<T> : WeakReference
    {
        public WeakReference(T target)
            : base(target)
        { }
        
        [SecuritySafeCritical]
        public WeakReference(T target, bool trackResurrection)
            : base(target, trackResurrection)
        { }

        [SecuritySafeCritical]
        protected WeakReference(SerializationInfo info, StreamingContext context)
            : base(info, context)
        { }

        public new T Target
        {
            get { return (T)base.Target; }
            set { base.Target = value; }
        }

        public static implicit operator T(WeakReference<T> weakReference)
        {
            return weakReference.Target;
        }
    }
}